package com.ruoyi.device.service.impl;

import java.util.List;
import com.ruoyi.common.core.utils.DateUtils;
import com.ruoyi.common.datascope.annotation.DataScope;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.device.mapper.TBuildingMapper;
import com.ruoyi.device.domain.TBuilding;
import com.ruoyi.device.service.ITBuildingService;

import static com.ruoyi.common.security.utils.SecurityUtils.getLoginUser;

/**
 * 建筑Service业务层处理
 * 
 * @author li
 * @date 2025-09-22
 */
@Service
public class TBuildingServiceImpl implements ITBuildingService 
{
    @Autowired
    private TBuildingMapper tBuildingMapper;

    /**
     * 查询建筑
     * 
     * @param id 建筑主键
     * @return 建筑
     */
    @Override
    public TBuilding selectTBuildingById(String id)
    {
        return tBuildingMapper.selectTBuildingById(id);
    }

    /**
     * 查询建筑列表
     * 
     * @param tBuilding 建筑
     * @return 建筑
     */
    @DataScope(deptAlias = "d")
    @Override
    public List<TBuilding> selectTBuildingList(TBuilding tBuilding)
    {
        return tBuildingMapper.selectTBuildingList(tBuilding);
    }

    /**
     * 新增建筑
     * 
     * @param tBuilding 建筑
     * @return 结果
     */
    @Override
    public int insertTBuilding(TBuilding tBuilding)
    {
        tBuilding.setCreateBy(getLoginUser().getUsername());
        tBuilding.setCreateTime(DateUtils.getNowDate());
        return tBuildingMapper.insertTBuilding(tBuilding);
    }

    /**
     * 修改建筑
     * 
     * @param tBuilding 建筑
     * @return 结果
     */
    @Override
    public int updateTBuilding(TBuilding tBuilding)
    {
        tBuilding.setUpdateBy(getLoginUser().getUsername());
        tBuilding.setUpdateTime(DateUtils.getNowDate());
        return tBuildingMapper.updateTBuilding(tBuilding);
    }

    /**
     * 批量删除建筑
     * 
     * @param ids 需要删除的建筑主键
     * @return 结果
     */
    @Override
    public int deleteTBuildingByIds(String[] ids)
    {
        return tBuildingMapper.deleteTBuildingByIds(ids);
    }

    /**
     * 删除建筑信息
     * 
     * @param id 建筑主键
     * @return 结果
     */
    @Override
    public int deleteTBuildingById(String id)
    {
        return tBuildingMapper.deleteTBuildingById(id);
    }
}
